<template>
  <div class="crumb">
    <el-breadcrumb separator-icon="ArrowRight">
      <template v-for="route in breadcrumbs" :key="route.name">
        <el-breadcrumb-item :to="route.path">
          {{ route.name }}
        </el-breadcrumb-item>
      </template>
    </el-breadcrumb>
  </div>
</template>

<script setup lang="ts">
  import { computed } from 'vue'
  import useLoginStore from '@/store/login'
  import { mapPathToBreadcrumbs } from '@/utils/map-menus'
  import { useRoute } from 'vue-router'

  const loginStore = useLoginStore()
  const userMenus = loginStore.userMenus as any[]
  const $route = useRoute()
  const breadcrumbs = computed(() => mapPathToBreadcrumbs($route.path, userMenus, {}))
</script>

<style lang="scss" scoped>
  .crumb {
    :deep(.el-breadcrumb__item .el-breadcrumb__inner) {
      cursor: pointer;
    }
  }
</style>
